package app.core.thread;

import app.core.model.impl.User;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Guo.Yang
 * @version 1.0
 * @date 2023/1/15 17:23
 */
public abstract class MyRunnable implements Runnable {
    public static Map<String, User> sockets = new ConcurrentHashMap<>();

    /**
     * 单次消息允许的最大比特
     */
    public static final Integer BYTES_MAX_SIZE = 1024 * 20;
    /**
     * 会话字符编码
     */
    public static final String CHAR_SET="utf8";
    protected  final InputStream getInput(Socket socket){
        try {
            return socket.getInputStream();
        } catch (IOException e) {
            System.out.println("获取输入流失败:"+ e.getMessage());
        }
        return null;
    }

    protected  final OutputStream getOutput(Socket socket){
        try {
            return socket.getOutputStream();
        } catch (IOException e) {
            System.out.println("获取输出流失败:"+ e.getMessage());
        }
        return null;
    }
}
